<?php

/*
  | --------------------------------------------------------------------------------------------------
  | <editar_servico_view>
  |
  | Desenvolvedor:	Eduardo Sirangelo
  | E-mail:		sirangelos@ibest.com.br
  | Descrição:
  |	-
  | Quality is Everyting
  | --------------------------------------------------------------------------------------------------
 */
?>
<script src="<?=base_url()?>public/js/cadastros/novo_servico.js"></script>

<section class="grid_8">
    
    <div class="block-border">
        
        <?
        $attributes = array('class' => 'block-content form', 'id' => 'formServico');
        $hidden     = array("id_servico" => $row->id_servico);
        echo form_open('/cadastros/update_servico/',$attributes,$hidden);

        ?>
            
            <h1>Edição de Serviços</h1>

            <div class="columns">
                    
                    <div>

                            <div id="tab-global" class="tabs-content">

                                <div class="tabs-content">

                                        <div id="tab-locales">

                                                <div class="margin-bottom_10">
                                                    
                                                    <fieldset class="grey-bg">

                                                        <legend>Dados principais</legend>

                                                        <div class="required margin-bottom_10">
                                                                <label for="complex-title">Descrição</label>
                                                                <span class="relative">
                                                                        <input type="text" name="servico" id="servico" value="<?=$row->servico?>" class="full-width"/>
                                                                        <span class="check-ok"></span>
                                                                </span>
                                                        </div>
                                                        
                                                    </fieldset>
                                                    
                                                </div>

                                                <ul class="mini-tabs no-margin js-tabs same-height">
                                                        <li class="current"><a href="#tab-vd">Valores</a></li>
                                                        <li><a href="#tab-ac">Acrescimos</a></li>
                                                        <li><a href="#tab-de">Descontos</a></li>
                                                        <li><a href="#tab-co">Configurações</a></li>
                                                </ul>

                                                <div id="tab-vd">
                                                    
                                                    <fieldset>
                                                        
                                                        <legend>Valor de Serviço & Comissão</legend>
                                                        
                                                        <div class="columns">
                                                            <p class="colx2-left">
                                                                <label for="">Valor do Serviço</label>
                                                                <input type="text" name="vl_servico" id="vl_servico" value="<?=$row->vl_servico?>" class="full-width" setMoney="true"/>
                                                            </p>
                                                        </div>

                                                        <div class="columns">

                                                            <p class="colx2-left">
                                                                
                                                                <label>Forma de comissão</label>

                                                                <?
                                                                if($row->tp_comissao == 0) {
                                                                    $checked_perc = 'checked="checked"';
                                                                    $checked_val  = '';
                                                                } elseif($row->tp_comissao == 1) {
                                                                    $checked_val  = 'checked="checked"';
                                                                    $checked_perc = '';
                                                                }
                                                                ?>
                                                                <label for="tp_comissao_percent" class="float-left margin-right">Percentual (%)</label>
                                                                <span class="float-left">
                                                                    <input type="checkbox" name="tp_comissao" id="tp_comissao_percent" value="0" title="Tipo de comissão por percentual" class="mini-switch with-tip tp_comissao" <?=$checked_perc?>/>
                                                                </span>                                                                    
                                                                <label for="tp_comissao_value" class="float-left margin-left margin-right">Valor (R$)</label>
                                                                <span class="float-left">
                                                                    <input type="checkbox" name="tp_comissao" id="tp_comissao_value" value="1" title="Tipo de comissão por valor" class="mini-switch with-tip tp_comissao" <?=$checked_val?>/>
                                                                </span>
                                                                
                                                            </p>

                                                        </div>
                                                        
                                                        <div class="columns">
                                                            
                                                            <p class="colx2-left">
                                                                <label for="">Comissão (<span id="tp_comissao_label">%</span>)</label>
                                                                <input type="text" name="vl_comissao" id="vl_comissao" value="<?=$row->comissao?>" class="full-width" setMoney="true"/>
                                                            </p>
                                                            
                                                        </div>
                                                        
                                                    </fieldset>
                                                    
                                                </div>

                                                <div id="tab-ac">    
                                                    
                                                    <fieldset>
                                                        
                                                        <legend>Valor de Acréscimo / Dia da Semana</legend>
                                                            
                                                            <?
                                                            
                                                            foreach($array_dias as $id_dia_semana => $data2) {
                                                                
                                                                if($data2[1] != "" && $data2[3] != "") {
                                                                    $checked_dia_semana     = 'checked="checked"';
                                                                    $disabled_dia_semana    = "";
                                                                    if($data2[2] == 0) {
                                                                        $checked_acre_perc  = 'checked="checked"';
                                                                        $checked_acre_val   = "";
                                                                    } elseif($data2[2] == 1) {
                                                                        $checked_acre_perc  = "";
                                                                        $checked_acre_val   = 'checked="checked"';
                                                                    }
                                                                    $vl_acrescimo           = $data2[3];
                                                                } else {
                                                                    $checked_dia_semana     = "";
                                                                    $disabled_dia_semana    = "disabled='disabled'";
                                                                    $checked_acre_perc      = "";
                                                                    $checked_acre_val       = "";
                                                                    $vl_acrescimo           = "";
                                                                }
                                                                ?>
                                                        
                                                                <div class="columns">

                                                                        <p class="colx3-left">
                                                                            <label for="dia_acrescimo_<?=$id_dia_semana?>" class="float-left size-75"><?=$data2[0]?></label>
                                                                            <input type="checkbox" name="dia_acrescimo_<?=$id_dia_semana?>" id="dia_acrescimo_<?=$id_dia_semana?>" value="<?=$id_dia_semana?>" class="mini-switch with-tip dia_semana_acrescimo" title="Habilitar/Desabilitar dia da semana" <?=$checked_dia_semana?>/>
                                                                        </p>

                                                                        <p class="colx3-center">
                                                                            
                                                                            <label for="tp_acrescimo_percent_<?=$id_dia_semana?>" class="float-left margin-right">%</label>
                                                                            <span class="float-left">
                                                                                <input type="checkbox" name="tp_acrescimo_<?=$id_dia_semana?>" id="tp_acrescimo_percent_<?=$id_dia_semana?>" value="0" class="mini-switch with-tip tp_acrescimo" title="Percentual" <?=$disabled_dia_semana?> <?=$checked_acre_perc?>/>
                                                                            </span>
                                                                            
                                                                            <label for="tp_acrescimo_value_<?=$id_dia_semana?>" class="float-left margin-left margin-right">R$</label>
                                                                            <span class="float-left">
                                                                                <input type="checkbox" name="tp_acrescimo_<?=$id_dia_semana?>" id="tp_acrescimo_value_<?=$id_dia_semana?>" value="1" class="mini-switch with-tip tp_acrescimo" title="Valor" <?=$disabled_dia_semana?> <?=$checked_acre_val?>/>
                                                                            </span>
                                                                        </p>

                                                                        <p class="colx3-right">
                                                                            <input type="text" name="vl_acrescimo_dia_<?=$id_dia_semana?>" id="vl_acrescimo_dia_<?=$id_dia_semana?>" value="<?=$vl_acrescimo?>" class="size-45 float-right" setMoney="true" <?=$disabled_dia_semana?>/>
                                                                        </p>

                                                                </div>
                                                        
                                                                <?
                                                            }
                                                            ?>
                                                        
                                                    </fieldset>
                                                    
                                                </div>
                                            
                                                <div id="tab-de">
                                                    
                                                    <fieldset>
                                                        
                                                        <legend>Valor de Desconto / Dia da Semana</legend>
                                                        
                                                            <?
                                                            foreach($array_dias as $id_dia_semana => $data2) {
                                                                
                                                                if($data2[1] != "" && $data2[5] != "") {
                                                                    $checked_dia_semana     = 'checked="checked"';
                                                                    $disabled_dia_semana    = "";
                                                                    if($data2[4] == 0) {
                                                                        $checked_desc_perc  = 'checked="checked"';
                                                                        $checked_desc_val   = "";
                                                                    } elseif($data2[4] == 1) {
                                                                        $checked_desc_perc  = "";
                                                                        $checked_desc_val   = 'checked="checked"';
                                                                    }
                                                                    $vl_desconto            = $data2[5];
                                                                } else {
                                                                    $checked_dia_semana     = "";
                                                                    $disabled_dia_semana    = "disabled='disabled'";
                                                                    $checked_desc_perc      = "";
                                                                    $checked_desc_val       = "";
                                                                    $vl_desconto            = "";
                                                                }

                                                                ?>
                                                        
                                                                <div class="columns">

                                                                        <p class="colx3-left">
                                                                            <label for="dia_desconto_<?=$id_dia_semana?>" class="float-left size-75"><?=$data2[0]?></label>
                                                                            <input type="checkbox" name="dia_desconto_<?=$id_dia_semana?>" id="dia_desconto_<?=$id_dia_semana?>" value="<?=$id_dia_semana?>" class="mini-switch with-tip dia_semana_desconto" title="Habilitar/Desabilitar dia da semana" <?=$checked_dia_semana?>/>
                                                                        </p>

                                                                        <p class="colx3-center">
                                                                            
                                                                            <label for="tp_desconto_percent_<?=$id_dia_semana?>" class="float-left margin-right">%</label>
                                                                            <span class="float-left">
                                                                                <input type="checkbox" name="tp_desconto_<?=$id_dia_semana?>" id="tp_desconto_percent_<?=$id_dia_semana?>" value="0" class="mini-switch with-tip tp_desconto" title="Percentual" <?=$disabled_dia_semana?> <?=$checked_desc_perc?>/>
                                                                            </span>
                                                                            
                                                                            <label for="tp_desconto_value_<?=$id_dia_semana?>" class="float-left margin-left margin-right">R$</label>
                                                                            <span class="float-left">
                                                                                <input type="checkbox" name="tp_desconto_<?=$id_dia_semana?>" id="tp_desconto_value_<?=$id_dia_semana?>" value="1" class="mini-switch with-tip tp_desconto" title="Valor" <?=$disabled_dia_semana?> <?=$checked_desc_val?>/>
                                                                            </span>
                                                                        </p>

                                                                        <p class="colx3-right">
                                                                            <input type="text" name="vl_desconto_dia_<?=$id_dia_semana?>" id="vl_desconto_dia_<?=$id_dia_semana?>" value="<?=$vl_desconto?>" class="size-45 float-right" setMoney="true" <?=$disabled_dia_semana?>/>
                                                                        </p>

                                                                </div>
                                                        
                                                                <?
                                                            }
                                                            ?>
                                                        
                                                    </fieldset>
                                                    
                                                </div>
                                            
                                                <div id="tab-co">
                                                    <p class="colx2-left">
                                                        <label for="tp_servico">Tempo do serviço (Minutos)</label>
                                                        <input type="text" name="tp_servico" id="tp_servico" value="<?=$row->tp_servico?>" class="full-width" setNumbers10="true"/>
                                                    </p>
                                                </div>
                                            
                                        </div>
                                </div>
                                
                            </div>

                    </div>

            </div>
            
            <fieldset class="grey-bg no-margin">
                    <legend>Salve seu trabalho</legend>
                    
                    <p class="input-with-button">
                        <button type="submit" class="float-right">Editar</button>
                        <img src="<?=base_url()?>public/images/ajax-loading.gif" alt="" class="ajax-loading-edit" id="ajax-loading"/>
                    </p>
                    
            </fieldset>

        </form>
    
    </div>
    
    <div id="content_loading_form">
        <img src="<?=base_url()?>public/images/icons/web-app/48/Info.png" alt=""/>
        <p id="text_return"></p>
        <button type="button" class="float-right" id="close_message">Ok</button>
    </div>
    
</section>